package cn.kgc.fcm.dsbank.service.impl;

import cn.kgc.fcm.dsbank.dto.ResultDTO;
import cn.kgc.fcm.dsbank.entity.ProvinceCityDistrict;
import cn.kgc.fcm.dsbank.mapper.ProvinceCityDistrictMapper;
import cn.kgc.fcm.dsbank.service.ProvinceCityDistrictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class ProvinceCityDistrictServiceImpl implements ProvinceCityDistrictService {

    @Autowired
    private ProvinceCityDistrictMapper provinceCityDistrictMapper;

    @Override
    public ResultDTO<List<ProvinceCityDistrict>> selectProvinceCityDistrictByPid(Integer pid) {

        List<ProvinceCityDistrict> provinceCityDistricts = provinceCityDistrictMapper.selectProvinceCityDistrictByPid(pid);

        if (CollectionUtils.isEmpty(provinceCityDistricts)){
            return ResultDTO.buildError();
        }
        return ResultDTO.buildSuccess(provinceCityDistricts);
    }
}
